package org.hzy.advices;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class MyAdvice {
	public void doBefore(JoinPoint jp){
		System.out.println(jp.getTarget());
		System.out.println(jp.getArgs()[0]);
		System.out.println(jp.getSignature().getName());
		System.out.println("this is doBefore");
	}
	public void doAfter(JoinPoint jp,Object ss){
		System.out.println(ss);
		System.out.println("this is doAfter");
	}
	
	public void doThrow(JoinPoint jp,Exception ex){//在异常发生前调用
		System.out.println(ex+"   "+ex.getMessage());
		System.out.println("this is doThrow");
	}
	public void doAround(ProceedingJoinPoint pjp) throws Throwable{//Throwable异常比exception异常高
		System.out.println("this is doAround");
		if(Integer.parseInt(pjp.getArgs()[0].toString())<10){
			System.out.println("小于10");
		}else{
			Object o=pjp.proceed(new Object[]{new Integer(20),"hzy"});
			System.out.println(o);
		}
	}
}
